<?
jimport('joomla.application.component.controller');
class NvControllerformrestoran extends JController{

	function display()
	{
	$mbuh = JRequest::getVar('task');
		if (empty($mbuh)||$mbuh=='cancel'){
		JRequest::setVar( 'view'  , 'restoran');
		JRequest::setVar( 'edit', false );
		
		parent::display();
		}
		else {
		JRequest::setVar( 'view'  , 'formrestoran');
		JRequest::setVar( 'layout'  , 'formtambah');
		JRequest::setVar( 'edit', false );
		
		parent::display();
		}
	}
	function edit()
	{
		JRequest::setVar( 'view', 'formrestoran' );
		JRequest::setVar( 'layout', 'formtambah'  );
		JRequest::setVar('hidemainmenu', 0);

		parent::display();
	}

    /*
     * fungsi ini digunakan untuk melakukan penyimpanan terhadap data.
     */
	function save()
	{
        // memanggil model form
		$model = $this->getModel('formrestoran');

		$post	= JRequest::get('post');
		$cid	= JRequest::getVar( 'cid', array(0), 'post', 'array' );
		$post['id'] = (int) $cid[0];

		if ($model->store($post)) {
			$msg = JText::_( 'Data disimpan' );
		} else {
			$msg = JText::_( 'Data tidak bisa disimpan' );
		}

		$this->setRedirect(JRoute::_('index.php?option=com_nv&view=restoran', false), $msg);
	}

    function remove()
	  {
	    // memanggil model form
		$model = $this->getModel('formrestoran');
        $cid = JRequest::getVar( 'cid', array(), '', 'array' );

        if ($model->delete($cid)) {
			$msg = JText::_( 'Data dihapus' );
		} else {
			$msg = JText::_( 'Data tidak bisa dihapus' );
		}
        
        $this->setRedirect(JRoute::_('index.php?option=com_nv&view=restoran', false), $msg);

	  }// end of function remove


}

?>